package com.unione.unione_base.view

import android.os.Handler
import android.os.Looper
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 * 为后面扩展用
 */
open class BaseViewModel : ViewModel() {
     var TIMEOUT = 15 * 1000 //超时时间
    //处理超时
    var mHandler = Handler(Looper.getMainLooper())
    val liveDataTimeOut = MutableLiveData<Boolean>()
     fun addTimeout() {
        mHandler.postDelayed(timeoutRunable, TIMEOUT.toLong())
    }

     fun removeTimeout() {
        mHandler.removeCallbacks(timeoutRunable)
    }
    private var timeoutRunable = Runnable { liveDataTimeOut.postValue(true) }
}